package jp.co.sopia;

import jp.co.sopia.bean.NoteBean;
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;

public class BasicTab extends Activity {
	static final int TIME_DIALOG = 1; 
	private Button setTimeBt;
	private EditText nameNote;
	private RadioGroup importanceChk;
	private EditText contentNote;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.basic);
		
		setTimeBt = (Button) findViewById(R.id.SetTimeBt);
		showDialog(TIME_DIALOG);
		
		nameNote = (EditText) findViewById(R.id.name_note);
		importanceChk = (RadioGroup) findViewById(R.id.importanceChk);
		contentNote = (EditText) findViewById(R.id.content_note);
		
		Bundle receiveBundle = this.getIntent().getExtras();
		if(receiveBundle != null) {
			setInitData(receiveBundle);
		}

	}
	
	@Override
	protected Dialog onCreateDialog(int id) {
		// TODO Auto-generated method stub
		return super.onCreateDialog(id);
	}
	
	private void setInitData(Bundle receiveBundle) {
		NoteBean note = (NoteBean) receiveBundle.getSerializable("note");
		nameNote.setText(note.getName());
		contentNote.setText(note.getContent());
		importanceChk.clearCheck();
		switch (note.getImportance()) {
			case R.id.high : {
				importanceChk.check(R.id.high);
				break;
			}
			case R.id.low : {
				importanceChk.check(R.id.low);
				break;
			}
			case R.id.medium : {
				importanceChk.check(R.id.medium);
				break;
			}
		}
		
	}

	public EditText getNameNote() {
		return nameNote;
	}

	public void setNameNote(EditText nameNote) {
		this.nameNote = nameNote;
	}
	
}
